package com.vipymh.springbootmybatisdemo.validation;

import com.vipymh.springbootmybatisdemo.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class StateValidation implements ConstraintValidator<State, String> {

    /**
     * @param s 将来要效验的数据
     * @param constraintValidatorContext 约束验证器内容
     * @return 返回结果  false 不通过  true 通过
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        // 提供效验规则

        if (s == null) {
            return false;
        }
        if (s.equals("已发布") || s.equals("草稿")) {
            return true;
        }
        return false;
    }
}
